package com.quick.controller;

import com.quick.service.SoaMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName InvockController
 * @Description TODO
 * @Author wangxin43
 * @Date 2018/7/4 下午12:08
 * @Version 1.0
 **/
@Controller
@RequestMapping("/soa")
public class InvockController {
	@Autowired
	private SoaMonitorService soaMonitorService;

	@ResponseBody
	@RequestMapping(value = {"/{service}/{method}"}, method = {RequestMethod.GET, RequestMethod.POST},produces = "application/json;charset=UTF-8")
	public Object jsonQueryDeliveryCompany(@PathVariable("service") String service, @PathVariable("method") String method, @RequestBody String jsonData, String pwd) {
		try {
			return soaMonitorService.invokeServiceMethod(jsonData, service, method, null, pwd);
		} catch (Exception e) {
			return e.getMessage();
		}
	}

	@ResponseBody
	@RequestMapping(value = {"/{service}/{method}/{methodId}"}, method = {RequestMethod.GET, RequestMethod.POST},produces = "application/json;charset=UTF-8")
	public Object jsonQueryDeliveryCompany(@PathVariable("service") String service, @PathVariable("method") String method, @PathVariable("methodId") Integer methodId, @RequestBody String jsonData, String pwd) {
		try {
			return soaMonitorService.invokeServiceMethod(jsonData, service, method, methodId, pwd);
		} catch (Exception e) {
			return e.getMessage();
		}
	}
}
